package calorie.com.calorie.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.lxh.baselibray.base.XActivity;
import com.lxh.baselibray.util.ObjectUtils;
import com.lxh.baselibray.util.SPUtils;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import calorie.com.calorie.R;
import calorie.com.calorie.constant.Constant;
import calorie.com.calorie.util.StaticValue;

//收货信息
public class ReceivingInformationActivity extends XActivity {


    @BindView(R.id.tv_name)
    TextView tvName;
    @BindView(R.id.tv_name_value)
    TextView tvNameValue;
    @BindView(R.id.tv_phone)
    TextView tvPhone;
    @BindView(R.id.tv_phone_value)
    TextView tvPhoneValue;
    @BindView(R.id.tv_receive_address)
    TextView tvReceiveAddress;
    @BindView(R.id.tv_receive_address_value)
    TextView tvReceiveAddressValue;

    @Override
    public void initData(Bundle savedInstanceState) {
        if (!ObjectUtils.isEmpty(StaticValue.user)) {
            tvNameValue.setText(SPUtils.getString(Constant.RECEIVE_NAME,null,context));
            tvPhoneValue.setText(SPUtils.getString(Constant.RECEIVE_PHONE,null,context));
            tvReceiveAddressValue.setText(SPUtils.getString(Constant.RECEIVE_ADDRESS,null,context));

//            tvNameValue.setText(StaticValue.user.getReceivingName());//获取收货姓名
//            tvPhoneValue.setText(StaticValue.user.getReceivingPhone());//获取收货电话
//            tvReceiveAddressValue.setText(StaticValue.user.getReceivingAddress());//获取收货地址
        }
    }
    @Override
    protected void onResume() {
        super.onResume();
        initData(null);
    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_receiving_information;
    }


    @OnClick({R.id.tv_name, R.id.tv_phone, R.id.tv_receive_address})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_name://姓名
                gotoModifyMsg(1);
                break;
            case R.id.tv_phone://手机号
                gotoModifyMsg(2);
                break;
            case R.id.tv_receive_address://收货地址
                gotoModifyMsg(3);
                break;
        }
    }

    private void gotoModifyMsg(int from) {
        Intent intent = new Intent(context, ModifyReceivingInformationActivity.class);
        intent.putExtra(ModifyReceivingInformationActivity.FROM, from);
        startActivity(intent);
    }
}
